#include <stdio.h>
#include <stdbool.h>
#include <math.h>

bool isPrime(int num) {
    if (num <= 1) return false;   
    if (num == 2) return true;   
    if (num % 2 == 0) return false;
    for (int i = 3; i <= sqrt(num); i += 2) {
        if (num % i == 0) return false;
    }
    return true;
}

int main() {
    int count = 0;
    for (int num = 2; num <= 20000; num++) {
        if (isPrime(num)) {
            printf("%6d", num); 
            count++;
            if (count % 5 == 0) printf("\n"); 
        }
    }
    printf("\n");
    return 0;
}
